package org.qianji.goosql.cond;

import org.qianji.goosql.dql.QueryStatement;
import org.qianji.goosql.field.Field;
import org.qianji.goosql.operator.Comparator;

public final class Conditions {

	public static Condition lt(Field leftField, Field rightField) {
		return new FieldCondition(leftField, Comparator.LT, rightField);
	}

	public static Condition lt(Field field, Object value) {
		return new ValueCondition(field, Comparator.LT, value);
	}

	public static Condition le(Field leftField, Field rightField) {
		return new FieldCondition(leftField, Comparator.LE, rightField);
	}

	public static Condition le(Field field, Object value) {
		return new ValueCondition(field, Comparator.LE, value);
	}

	public static Condition eq(Field leftField, Field rightField) {
		return new FieldCondition(leftField, Comparator.EQ, rightField);
	}

	public static Condition eq(Field field, Object value) {
		return new ValueCondition(field, Comparator.EQ, value);
	}

	public static Condition gt(Field leftField, Field rightField) {
		return new FieldCondition(leftField, Comparator.GT, rightField);
	}

	public static Condition gt(Field field, Object value) {
		return new ValueCondition(field, Comparator.GT, value);
	}

	public static Condition ge(Field leftField, Field rightField) {
		return new FieldCondition(leftField, Comparator.GE, rightField);
	}

	public static Condition ge(Field field, Object value) {
		return new ValueCondition(field, Comparator.GE, value);
	}

	public static Condition ne(Field leftField, Field rightField) {
		return new FieldCondition(leftField, Comparator.NE, rightField);
	}

	public static Condition ne(Field field, Object value) {
		return new ValueCondition(field, Comparator.NE, value);
	}

	public static Condition in(Field field, Object... values) {
		return new InValues(field, values);
	}

	public static Condition in(Field field, QueryStatement subQuery) {
		return new InSubQuery(field, subQuery);
	}

	public static Condition like(Field field, String value, LikeMode likeMode) {
		return new ValueCondition(field, Comparator.LIKE, likeMode.toLikeString(value));
	}

	public static Condition btw(Field field, Object leftValue, Object rightValue) {
		return new Between(field, leftValue, rightValue);
	}

	public static Condition and(Condition... conds) {
		return new And(conds);
	}

	public static Condition or(Condition... conds) {
		return new Or(conds);
	}

	public static Condition not(Condition cond) {
		return new Not(cond);
	}

}
